package server;

import server.core.IMyRemote;
import server.core.MyRemoteImpl;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 * describe: 服务提供者发布服务
 *
 * @author helloworldyu
 * @data 2018/3/26
 */
public class ServerMain {
	public static void main(String[] args) {
		try {
			//以1099作为LocateRegistry接收客户端请求的端口，并注册服务的映射关系
			Registry registry= LocateRegistry.createRegistry(1099);

			IMyRemote server = new MyRemoteImpl();
			Naming.rebind("rmi://localhost:1099/hello", server);
			System.out.println("remote server start");
		}catch (RemoteException e){
			e.printStackTrace();
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}
}